package com.yubest.demo.util;

import com.yubest.demo.bean.LoginBean;

import java.util.Optional;

/**
 * @Author hweiyu
 * @Description
 * @Date 2022/1/21 10:00
 */
public class LoginUtil {

    /**
     * 模拟从会话中获取当前登陆的用户信息
     * @return
     */
    public static LoginBean getUser() {
        return new LoginBean().setId(1L).setUserName("admin");
    }

    public static String getUserName() {
        return Optional.ofNullable(getUser())
                .map(LoginBean::getUserName)
                .orElse(null);
    }
}
